﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sy2_9
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
      
          
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
        private void btnEncryptDecrypt_Click(object sender, EventArgs e)
        {
            // 调用 ROT13 方法处理文本框内容
            txtInput.Text = Rot13Helper.Rot13String(txtInput.Text);

            // 切换按钮文本（加密/解密）
            btnEncryptDecrypt.Text = btnEncryptDecrypt.Text == "加密" ? "解密" : "加密";
        }

        private void btnEncryptDecrypt_Click_1(object sender, EventArgs e)
        {
            string input = txtInput.Text;
            StringBuilder result = new StringBuilder();
            foreach (char c in input)
            {
                // 对每个字符应用 ROT13 转换
                result.Append(Rot13(c));
            }
            txtInput.Text = result.ToString();
            // 切换按钮文本，实现加密/解密切换
            btnEncryptDecrypt.Text = btnEncryptDecrypt.Text == "加密" ? "解密" : "加密";
        }

        private void btnReset_Click(object sender, EventArgs e)
        {
            // 清空文本框
            txtInput
        .Clear();
            // 重置按钮文本为 “加密”
            btnEncryptDecrypt
        .Text = "加密";
            // 将焦点设置到文本框
            txtInput
        .Focus();
        }
    } 
}
